<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">

    <title>修改密码</title>
    <link rel="shortcut icon" href="/img/favicon.ico">

    <!-- global stylesheets -->
    <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/font-awesome-4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/font-icon-style.css">
    <link rel="stylesheet" href="/css/style.default.css" id="theme-stylesheet">

    <!-- Core stylesheets -->
    <link rel="stylesheet" href="/css/form.css">
</head>
<script src="/js/jquery-3.4.1.js"></script>
<script type="text/javascript">

    function check() {   //密码判断
        var oldPassword = document.forms["myForms"]["oldPassword"].value;
        var newPassword = document.forms["myForms"]["newPassword"].value;
        var confirmNewPassword = document.forms["myForms"]["confirmNewPassword"].value;
        var flagPass = false;
        if (oldPassword==null||oldPassword==""){
            alert("原密码不能为空");
            return false;
        }
        if (oldPassword.length<6){
            alert("原密码长度不少于6位");
            return  false;
        }
        if (newPassword==""||confirmNewPassword==""){
            alert("新密码不能为空");
            return false;
        }
        if (newPassword.length<6&&confirmNewPassword.length<6){
            alert("新密码长度不能少于6位字符");
            return false;
        }
        if (newPassword!=confirmNewPassword){
            alert("新密码与确认密码不符");
            return  false;
        }

        $.ajax({
            url:"/center/checkPassword",
            type:"post",
            data:{"oldPassword":oldPassword},
            async:false,
            success:function(result){
                if(result.code == 200){
                    alert("密码更新成功");
                    flagPass=true;
                }
                else if(result.code==100){
                    alert("原密码不正确");
                    flagPass=false;
                }
            }
        });
        return flagPass;
    }

</script>

<body>
<div class="content-inner form-cont">
    <div class="row">
        <div class="col-md-12">
            <!--***** FORM INPUTS *****-->
            <div class="card form" id="form">
                <div class="card-header">
                    <h3>修改密码</h3>
                </div>
                <br>

                <form action="/center/updatePassword" method="post" name="myForms" onsubmit="return check()">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="exampleInputPassword1">旧密码</label>
                                <input name="oldPassword" type="password" class="form-control" placeholder="旧密码">
                            </div>
                            <div class="form-group">
                                <label for="exampleInputPassword1">新密码</label>
                                <input name="newPassword" type="password" class="form-control" placeholder="新密码">
                            </div>
                            <div class="form-group">
                                <label for="exampleInputPassword1">确认新密码</label>
                                <input name="confirmNewPassword" type="password" class="form-control" placeholder="确认新密码">
                            </div>
                            <button type="submit" class="btn btn-general btn-blue mr-2">提交</button>
                            <button type="reset" class="btn btn-general btn-white">重置</button>

                        </div>
                    </div>
                </form>



            </div>
        </div>
    </div>
</div>


</body>


</html>